/*
 * @(#)UsfServiceExecutorTester.java $version 2010. 8. 11
 *
 * Copyright 2007-2010 NHN Corp. All rights Reserved. 
 * NHN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.nhncorp.usf.core.service;

import java.util.Map;

import com.nhncorp.usf.core.config.runtime.Action;
import com.nhncorp.usf.core.config.runtime.Method;
import com.nhncorp.usf.core.config.runtime.Service;
import com.nhncorp.usf.test.DynamicConfigTester;
import com.nhncorp.usf.test.ExecuteInfo;

/**
 * {@link UsfServiceExecutor} 실행 기록을 남기는 용도로 만든 클래스 
 * {@link DynamicConfigTester} 를 사용할 경우 실행되는 {@link ServiceExecutor} 이다.  
 *
 * @author Web Platform Development Team
 */
public class UsfServiceExecutorTester extends UsfServiceExecutor {
	private ExecuteInfo executeInfo;
	
	public UsfServiceExecutorTester() {
	}

	/**
	 * {@inheritDoc}
	 * */
	@Override
	public RESULT_STATUS execute(Action action, Map<String, Object> dataStructure) throws Exception {
		executeInfo = new ExecuteInfo();
		RESULT_STATUS result =  super.execute(action, dataStructure);
		return result;
	}
	
	/**
	 * {@inheritDoc}
	 * */
	void logMethodExecutionInfo(Method method, ServiceExecutionContext context) {
		String boId = context.getBo().getId();
		String methodName = method.getName();
		
		executeInfo.addExecuteMethod(boId + "." + methodName, context.getMethodType());
	}

	/**
	 * {@inheritDoc}
	 * */
	@Override
	void logExecutionPath(Service service) {
		if (service == null) {
			return;
		}
		
		executeInfo.addExecutionPath(service);
	}
	
	/**
	 * @return {@link ExecuteInfo} 실행 결과를 반환한다.
	 * */
	public ExecuteInfo getExecuteInfo() {
		if (executeInfo == null) {
			executeInfo = new ExecuteInfo();
		}
		
		return executeInfo;
	}
}
